<?php
class Admin_Form_Game extends Zend_Form
{

    public function init()
    {
        $this->setName("game");
        $this->setAttrib('enctype','multipart/form-data');
        
        $gameId = new Zend_Form_Element_Text('gameId');
        $gameId->setLabel('Mã game')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        $gameId->setAttrib('size', 60);
        
        $gameName = new Zend_Form_Element_Text('gameName');
        $gameName->setLabel('Tên game')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        $gameName->setAttrib('size', 60);
        /*
        $modelCategories = new Admin_Model_Categories();
        $categoriesList = $modelCategories->getCategories();
        $catId = new Zend_Form_Element_Select('catId');
        $catId->setLabel('Danh mục game')->addValidator('alnum')->addValidator('NotEmpty');
        $catId->addMultiOption('','');
        if(isset($categoriesList)){
            foreach($categoriesList as $key=>$row){
                $catId->addMultiOption($row->catId,$row->catName);
            }
        }
        */
        $gameImg = new Zend_Form_Element_File('gameImg');
        $gameImg->setLabel('Hình ảnh');
        $gameImg->addValidator('Extension',true,array('jpg','gif','png'),'picture');
        $gameImg->addValidator('Size',true,array('min'=>'10KB','max'=>'2000KB'),'filezip'); 
        $gameImg->setAttrib('size', 60);
        
        $openDate = new Zend_Form_Element_Text('openDate');
        $openDate->setLabel('Ngày bắt đầu')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        $openDate->setAttrib('class', 'datepicker');
        $openDate->setAttrib('readonly', 'readonly');
        
        $level = new Zend_Form_Element_Text('level');
        $level->setLabel('Thứ tự ưu tiên')->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        $level->setAttrib('size', 60);

        $status = new Zend_Form_Element_Select('status');
        $status->setLabel('Trạng thái');
        $status->addMultiOption('1','Đang chạy');
        $status->addMultiOption('0','Đã dừng');
        
        $gameConfig = new Zend_Form_Element_Textarea('gameConfig');
        $gameConfig->setLabel('Cấu hình')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        
        // submit button
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setAttrib('id','submitbutton');
        $submit->setAttrib('class',"button medium");
                
        // add elements to form
        $this->addElements(array (
            $gameId, $gameName, $level, $gameImg, $openDate, $status, $submit//$catId, 
        ));
    }
}

